<!--<a onclick="javascript:scan()"></a>
<script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>-->
<script>

    function UrlEncode(str) {
        str = (str + '').toString();
        return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
        replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
    }

    function scan() {
        wx.scanQRCode({
            desc: 'scanQRCode desc',
            needResult: 0, // 默认为0，扫描结果由企业微信处理，1则直接返回扫描结果，
            scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码，默认二者都有
            success: function (res) {
                // 回调
            },
            error: function (res) {
                if (res.errMsg.indexOf('function_not_exist') > 0) {
                    alert('版本过低请升级')
                }
            }
        });
    }
	
	//设置APP客户标识
	localStorage.setItem("APP_FLAG","GTJA");
	//设置后台API访问地址
	localStorage.setItem("localurl","https://applink.gtja.net/MoblieAPP/api");
	//设置上传的图片的前缀地址
	localStorage.setItem("localurlfileurl","https://applink.gtja.net/MoblieAPP/ossfile/");
	
	var sss=window.location.search;
	//alert("进入app.html"+sss);
	//alert("appelse跳转");
	
	if(sss==null || sss==undefined || sss==""){
		//alert("sss为空跳转");
		localStorage.removeItem("LoginName");
		localStorage.removeItem("userInfo");
		localStorage.removeItem("authorization");
		localStorage.removeItem("userToken")
		localStorage.removeItem("userRoles");
		localStorage.removeItem("userDept");
		localStorage.removeItem("userReadDeptIds");
		localStorage.removeItem("managePositionIds");
		localStorage.removeItem("ASSETCODE");
		//allPositionIds
		//window.location.href = "index.html"+sss;
		window.location.href = "index.html#/pages/login/login";
	}else{
		//alert("sss不为空跳转");
		if(sss.indexOf("SSO")>-1){
			/*
			清理登录信息重新登录
			*/
			localStorage.removeItem("LoginName");
			localStorage.removeItem("userInfo");
			localStorage.removeItem("authorization");
			localStorage.removeItem("userToken")
			localStorage.removeItem("userRoles");
			localStorage.removeItem("userDept");
			localStorage.removeItem("userReadDeptIds");
			localStorage.removeItem("managePositionIds");
			localStorage.removeItem("ASSETCODE");
			
			//设置SSO信息
			localStorage.setItem("SSO",sss);
			//跳转

			//window.location.href = "index.html"+sss;
			window.location.href = "index.html#/pages/login/login";
		}else{
			
				let userInfo = localStorage.getItem("userInfo");
				if(userInfo==null || userInfo==undefined || userInfo==""){
					//没有登录信息，不通过app.html处理跳转，让自动跳到登录页处理
					localStorage.removeItem("LoginName");
					localStorage.removeItem("userInfo");
					localStorage.removeItem("authorization");
					localStorage.removeItem("userToken")
					localStorage.removeItem("userRoles");
					localStorage.removeItem("userDept");
					localStorage.removeItem("userReadDeptIds");
					localStorage.removeItem("managePositionIds");
					localStorage.removeItem("ASSETCODE");
					//alert("有登录缓存跳转");
					//window.location.href = "index.html"+sss;
					window.location.href = "index.html#/pages/login/login";
				}else{		
					//alert("没有登录缓存跳转");
					//获取扫码前存的页面信息
					var syshuitiao=localStorage.getItem("syshuitiao");
					if(syshuitiao=="" || syshuitiao==undefined || syshuitiao==null){
						//如果为空设置默认跳转页面并缓存
						syshuitiao='../asset/asset?Type=2';
						localStorage.setItem("syshuitiao",'../asset/asset?Type=2');
					}
					var ASSETCODE=sss;
					ASSETCODE=ASSETCODE.substr(1,ASSETCODE.length-1);
					var alist=ASSETCODE.split("&");
					var myassetcode="";
					for(var i=0;i<alist.length;i++){
						var str=alist[i];
						var strlist=str.split("=");
						if(strlist.length>1){
							if(strlist[0]=="assetcode"){
								myassetcode=strlist[1];
							}
						}
						if(syshuitiao.indexOf("StockDocumentAsset")>-1){					
							window.location.href = "index.html#/pages"+syshuitiao+"&AssetCode="+myassetcode;
						}else if(syshuitiao.indexOf("assetedit")>-1){
							window.location.href = "index.html#/pages"+syshuitiao+"&AssetCode="+myassetcode;
						}else if(syshuitiao.indexOf("asset")>-1){
							window.location.href = "index.html#/pages"+syshuitiao+"&AssetCode="+myassetcode;
						}
					}//AssetCode
				}
			
			
			
			window.location.href = "index.html"+sss;
		}
	}
			
    
	//https://applink.gtja.net/MoblieAPP/app.html/index.html#/pages/home/Index?LoginName=%E9%87%91%E6%80%A1
</script>
